using System.Data.Linq;

namespace PropertyExpression.ReactiveRelation.Test.Common
{
    public static class LinqUtil
    {
        public static void DeleteAll<T>(this Table<T> otherExpenses) where T : class
        {
            otherExpenses.DeleteAllOnSubmit(otherExpenses);
        }

        public static ICalcInitiator<T> Create<T>(
            this DataContext dataContext, ICalcExecutor calcExecutor) 
            where T : class, new()
        {
            var coupleEntity = calcExecutor.CreateAndCoupleEntity<T>();
            dataContext.GetTable<T>().InsertOnSubmit(coupleEntity.Entity);
            return coupleEntity;
        }
    }
}